﻿using Microsoft.Win32;
using OxyPlot.Wpf;
using System.Windows.Controls;
namespace IdResourceModule.Views
{
    /// <summary>
    /// Interaction logic for DataStatistics
    /// </summary>
    public partial class DataStatistics : UserControl
    {
        public DataStatistics()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveBitmap(PlotView plotView,string defaultFileName)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.FileName = defaultFileName;
           if ( saveFileDialog.ShowDialog()==true)
            {
               var fileName= saveFileDialog.FileName;
                try
                {
                    plotView.SaveBitmap(fileName);
                }catch 
                {
                }
            }
            
        }
       
      
      
          
     
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pvDBP_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            this.pvDBP.ResetAllAxes();
        }
        private void btnDBP_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            SaveBitmap(this.pvDBP, "Tekanan darah sistolik.png");
        }
        private void pvPulseRate_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            this.pvPulseRate.ResetAllAxes();
        }
        private void btnPvPulseRate_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            SaveBitmap(this.pvPulseRate, "Detak jantung.png");
        }
        private void pvSBP_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            pvSBP.ResetAllAxes();
        }
        private void btnPvSBP_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            SaveBitmap(this.pvSBP, "Tekanan darah diastolik.png");
        }
       
        private void pvBpLevel_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            this.pvBpLevel.ResetAllAxes();
        }
        private void btnPvBpLevel_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            SaveBitmap(this.pvBpLevel, "Penilaian tekanan darah.png");
        }
    }
}
